import "./App.css";

import React from "react";

class App extends React.Component {
  /**响应式数据 */
  state = {
    a: 2,
    b: 3,
    arr: [1, 2, 3],
  };

  addA = () => {
    this.setState({ a: ++this.state.a });
  };
  addB = () => {
    this.setState({ b: ++this.state.b });
  };
  addArr() {
    this.state.arr.push(5, 6);
    this.setState({
      arr: [this.state.arr],
    });
  }
  render() {
    return (
      <div className="App">
        <button onClick={this.addA}>{this.state.a}</button>
        <button onClick={this.addB}>{this.state.b}</button>

        <button onClick={this.addArr.bind(this)}>
          添加数组{this.state.arr}
        </button>
      </div>
    );
  }
}

export default App;
